package com.xs.ahoi.hcxs.ui.dialog;

import android.content.Context;
import android.view.Gravity;
import android.widget.TextView;
import butterknife.BindView;
import com.xs.ahoi.hcxs.R;
import com.xs.ahoi.hcxs.utils.StringUtils;

/**
 * loading弹窗页面
 */
public class DialogLoading extends BaseDialog {

    @BindView(R.id.tvInfo)
    public TextView tvInfo;

    private LoadingListener listener;
    private String text;


    public DialogLoading(Context context) {
        this(context, null);
    }

    public DialogLoading(Context context, String text) {
        super(context, R.style.common_dialog);
        this.text = text;
        setCanceledOnTouchOutside(false);
    }

    @Override
    public int getLayoutRes() {
        return R.layout.dialog_loading;
    }

    @Override
    protected int showPosition() {
        return Gravity.CENTER;
    }

    @Override
    protected void initData() {
        if (StringUtils.isNotEmpty(text)) {
            tvInfo.setText(text);
        }
    }

    public void setText(String text) {
        this.text = text;
    }

    public void show(String text) {
        setText(text);
        show();
    }

    @Override
    protected void onStart() {
        super.onStart();
        tvInfo.setText(text);
    }

    public void setListener(LoadingListener listener) {
        this.listener = listener;
    }

    public interface LoadingListener {

    }
}
